#include <iostream>
#include "RadixTree.h"
using namespace std;

void RadixTree::AddWord(char *word)
{
	char *p = word;
	rNode *currentNode=root;
	rNode *rn;
	for(;*p!='\0';p++)
	{
		if(currentNode->child[*p-'a']==NULL)
		{
			rn = new rNode;
			for(int i=0;i<27;i++)
				rn->child[i] = NULL;
			rn->color=false;
			rn->c = *p;
			currentNode->child[rn->c-'a'] = rn;
			currentNode = rn;
		}
		else
		{
			currentNode = currentNode->child[*p-'a'];
		}

		if(*(p+1)=='\0')
		{
			currentNode->color = true;
		}
	}
}